/*
* CheckingAccount
*
* r1
*
* GNU General Public License v3.0
*/

package com.acme.bankapp.domain.bank;

public class CheckingAccount extends AbstractAccount {
	
	private double balance;
	private double overdraft;
	
	public CheckingAccount(double balance, double overdraft) {
		this.balance = balance;
		this.overdraft = overdraft;
	}
	
	public void deposit(double amount) {
		this.balance += amount;
	}

	public void withdraw(double amount) {
		if(this.balance + this.overdraft >= amount) {
			this.balance -= amount;
		}
		if(this.balance < 0) {
			this.overdraft += this.balance;
			this.balance = 0;
		}
	}
	
	public double getBalance() {
		return this.balance;
	}
	
	public double maximumAmountToWithdraw() {
		return this.balance + this.overdraft;
	}
	
}
